package time; /**
 * Meituan.com Inc.
 * Copyright (c) 2010-2019 All Rights Reserved.
 */

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * <p></p>
 *
 * @author tuyou@meituan.com
 * @version v0.1 2019-03-04 12:02 AM tuyou Exp $$
 */
public class DateTimeTest {
    public static void main(String[] args) {
        LocalDateTime localDate = LocalDateTime.now();
        System.out.println(localDate);

        ZonedDateTime zonedDateTime = localDate.atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(zonedDateTime);

        //DateTimeFormatter是线程安全的
        System.out.println(zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }
}